home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / piblist.arc / PIBLIST.DOC < prev    next >
Encoding:
Text File  |  1985-03-28  |  31.3 KB  |  398 lines

  1. (*---------------------------------------------------------------------------*)
  2. (*                                                                           *)
  3. (*   PIBLIST - A utility program for displaying text files on PC screens.    *)
  4. (*                                                                           *)
  5. (*   Introduction                                                            *)
  6. (*   ------------                                                            *)
  7. (*                                                                           *)
  8. (*      PIBLIST is a general-purpose utility program for displaying          *)
  9. (*      sequential ascii text files to the PC's screen.                      *)
  10. (*                                                                           *)
  11. (*      PIBLIST displays one screenful (or "window") of text at a time.      *)
  12. (*      A prompt called the "paging prompt" is displayed at the bottom       *)
  13. (*      of each screen.  Commands are provided to position the viewing       *)
  14. (*      window both vertically and horizontally within the file.             *)
  15. (*      Commands can be specified in either absolute or relative format,     *)
  16. (*      and in terms of lines, screens, pages, or columns.                   *)
  17. (*                                                                           *)
  18. (*                                                                           *)
  19. (*   Executing PIBLIST from DOS:                                             *)
  20. (*   --------- ------- ---- ---                                              *)
  21. (*                                                                           *)
  22. (*      PIBLIST  fname  /FF /LPC /T /H                                       *)
  23. (*                                                                           *)
  24. (*         fname  --- the ascii file name to be listed in the form:          *)
  25. (*                       driveletter:\path\filename.ext                      *)
  26. (*                    where                                                  *)
  27. (*                       driveletter  = the drive on which the file resides  *)
  28. (*                                      ( optional )                         *)
  29. (*                       \path\       = a subdirectory path ( optional )     *)
  30. (*                       filename.ext = the actual file name.                *)
  31. (*                                                                           *)
  32. (*                    Examples:                                              *)
  33. (*                                                                           *)
  34. (*                       c:\mydir\afile.doc                                  *)
  35. (*                       \mydir\another.mem                                  *)
  36. (*                       myfile.dat                                          *)
  37. (*                                                                           *)
  38. (*                    If the file name does not appear, PIBLIST prompts for  *)
  39. (*                    it.                                                    *)
  40. (*                                                                           *)
  41. (*         /FF    --- The file is divided into pages by form feed characters *)
  42. (*                    appearing in column one of the first line on a new     *)
  43. (*                    page.  The form feed is ascii character 12.            *)
  44. (*         /LPC   --- The file is divided into pages by character ones       *)
  45. (*                    appearing in column one of the first line on a new     *)
  46. (*                    page.  Such files are commonly created by FORTRAN      *)
  47. (*                    programs or files prepared for line printers on minis  *)
  48. (*                    and mainframes.                                        *)
  49. (*                                                                           *)
  50. (*         Note:  /FF and /LPC are mutually exclusive.  If both are given,   *)
  51. (*                the one which appears last is used.  If neither appears,   *)
  52. (*                the file is assumed to not be divided into pages.          *)
  53. (*                                                                           *)
  54. (*         /T     --- requests that tabs be expanded to sequences of blanks  *)
  55. (*                    when displayed ( optional )                            *)
  56. (*                                                                           *)
  57. (*         /H     --- requests that the high-order bit of each character     *)
  58. (*                    be stripped before the character is displayed.         *)
  59. (*                    ( optional )                                           *)
  60. (*                    This allows WordStar files to be displayed.            *)
  61. (*                    Note that this mode slows down PibList considerably,   *)
  62. (*                    so you shouldn't ask for bit-stripping unless you      *)
  63. (*                    need it.                                               *)
  64. (*                                                                           *)
  65. (*                                                                           *)
  66. (*   The paging prompt                                                       *)
  67. (*   --- ------ ------                                                       *)
  68. (*                                                                           *)
  69. (*      The following prompt is displayed at the bottom of each screen:      *)
  70. (*                                                                           *)
  71. (*      [Pa Sb Lc Cd We] ( Enter ? for help) ?                               *)
  72. (*                                                                           *)
  73. (*      The numbers a, b, c, d, and e specify the current page               *)
  74. (*      number, screen number, line number, column number, and               *)
  75. (*      width setting respectively.  The page, screen, and line              *)
  76. (*      numbers refer to the bottom (last) line in the currently             *)
  77. (*      displayed window.  The column number is the number of the            *)
  78. (*      leftmost column displayed in the window, where columns are           *)
  79. (*      numbered 1, 2, 3, and so on.  The width is the number of             *)
  80. (*      columns displayed for each line in the window.                       *)
  81. (*                                                                           *)
  82. (*   Commands                                                                *)
  83. (*   --------                                                                *)
  84. (*                                                                           *)
  85. (*      The commands described below can all be typed in response to any     *)
  86. (*      paging prompt.  All of the commands are single letters, but may be   *)
  87. (*      preceded or followed by direction indicator (+.-) and counts.        *)
  88. (*      In all cases the letter commands must be terminated by a carriage    *)
  89. (*      return.  Leading and trailing blanks are ignored.  Embedded blanks   *)
  90. (*      are ignored except inside numbers.  Letters may be typed in upper    *)
  91. (*      case, lower case, or any mixture of upper and lower case.  A lower   *)
  92. (*      case "n" below denotes any unsigned decimal integer.                 *)
  93. (*                                                                           *)
  94. (*      For convenience, the commonest commands may be entered by using the  *)
  95. (*      PC keypad keys.  In this case, no carriage return is needed.         *)
  96. (*                                                                           *)
  97. (*      For all of the relative positioning commands PIBLIST automatically   *)
  98. (*      resets the position to 1 if the result of adding the current         *)
  99. (*      position and the increment is negative or zero.  For example,        *)
  100. (*      if page 4 is currently displayed then the command "-10p" skips       *)
  101. (*      backwards to the beginning of the file (page 1).                     *)
  102. (*                                                                           *)
  103. (*      The "?" and "E" commands are used to display a command menu and exit *)
  104. (*      from the PIBLIST program respectively.                               *)
  105. (*                                                                           *)
  106. (*      ?: A menu is displayed summarizing all of the legal commands.        *)
  107. (*         The paging prompt is reissued at the bottom of the menu.          *)
  108. (*                                                                           *)
  109. (*      E, EX, EXI, or EXIT: The program terminates and returns to           *)
  110. (*         the calling environment.                                          *)
  111. (*                                                                           *)
  112. (*   Screen positioning commands                                             *)
  113. (*   ------ ----------- --------                                             *)
  114. (*                                                                           *)
  115. (*      These commands all position the viewing window vertically            *)
  116. (*      in terms of "screens".  A "screen" is defined to be a                *)
  117. (*      contiguous group of 24 lines.                                        *)
  118. (*                                                                           *)
  119. (*      Just carriage return: Display the next screen, i.e., display         *)
  120. (*         the group of 24 lines immediately following the current           *)
  121. (*         screen.                                                           *)
  122. (*      S, +, or +S: Display the next screen.  Same as just carriage         *)
  123. (*         return.                                                           *)
  124. (*         You can also use the keypad key PgDn.                             *)
  125. (*      - or -S: Display the previous screen, i.e., the group of 24          *)
  126. (*         lines immediately preceding the current screen.                   *)
  127. (*         You can also use the keypad key PgUp.                             *)
  128. (*      n, +n, nS, or +ns: Skip forwards n screens.                          *)
  129. (*      -n or -nS: Skip backwards n screens.                                 *)
  130. (*      Sn: Skip to absolute screen number n.                                *)
  131. (*                                                                           *)
  132. (*      Notes.  "0" redisplays the current screen.  This could be used,      *)
  133. (*      for example, after a message from the operator or another user       *)
  134. (*      or process, or after displaying the menu.  "S0" or "S1" can be       *)
  135. (*      used to skip backwards to the beginning of the file.  To view        *)
  136. (*      the last screen on the file (i.e., the last 24 lines), you could     *)
  137. (*      use "S9999" followed by "-".  "S9999" skips to the end of the        *)
  138. (*      file, and "-" backs up one screen.                                   *)
  139. (*                                                                           *)
  140. (*      The Home key (keypad key 7) can also be used to get to the start of  *)
  141. (*      the file, and the End key (keypad key 1) can be used to get to the   *)
  142. (*      end of the file.                                                     *)
  143. (*                                                                           *)
  144. (*   Page positioning commands                                               *)
  145. (*   ---- ----------- --------                                               *)
  146. (*                                                                           *)
  147. (*      These commands all position the viewing window vertically in         *)
  148. (*      terms of "pages".  For FORTRAN line printer carriage control files   *)
  149. (*      (/LPC) a new page is indicated by a line with a "1" in column 1.     *)
  150. (*      For non-line printer carriage control files (/FF) a new page is      *)
  151. (*      indicated by a line with a form feed in column 1.                    *)
  152. (*                                                                           *)
  153. (*      The relative page positioning commands all specify page              *)
  154. (*      numbers relative to the "current page number".  This is              *)
  155. (*      defined to be the page number of the line currently displayed        *)
  156. (*      at the top of the viewing window.  The current page number is        *)
  157. (*      denoted by "x" in the descriptions below.                            *)
  158. (*                                                                           *)
  159. (*      P or +P: Skip to the top of the next page, i.e., display the         *)
  160. (*         24 lines starting with the first line of page x+1.                *)
  161. (*      Ctrl-PgDn: Same as P.                                                *)
  162. (*                                                                           *)
  163. (*      -P: Skip backwards one page, i.e., display the 24 lines              *)
  164. (*         starting with the first line of page x-1.                         *)
  165. (*      Ctrl-PgUp: Same as -P.                                               *)
  166. (*                                                                           *)
  167. (*      nP or +nP: Skip forwards n pages, i.e., display the 24 lines         *)
  168. (*         starting with the first line of page x+n.                         *)
  169. (*      -nP: Skip backwards n pages, i.e., display the 24 lines              *)
  170. (*         starting with the first line of page x-n.                         *)
  171. (*      Pn: Skip to absolute page number n, i.e, display the 24              *)
  172. (*         lines starting with the first line of page n.                     *)
  173. (*                                                                           *)
  174. (*      Notes.  "0P" skips to the top of the current page.  This is          *)
  175. (*      usually not the same as redisplaying the current screen.             *)
  176. (*      For example, "P9999" followed by "0P" skips to the last              *)
  177. (*      page on the file.  "P9999" skips to the end of the file,             *)
  178. (*      and "0P" skips to the top of the current page, which is              *)
  179. (*      the last page.  If "-1P" were used instead of "0P" in this           *)
  180. (*      example then the second-to-last page would be displayed.             *)
  181. (*      "P0" or "P1" can be used to skip backwards to the beginning          *)
  182. (*      of the file.                                                         *)
  183. (*                                                                           *)
  184. (*   Line positioning commands                                               *)
  185. (*   ---- ----------- --------                                               *)
  186. (*                                                                           *)
  187. (*      These commands all position the viewing window vertically            *)
  188. (*      in terms of lines.  PIBLIST numbers the lines of text on the         *)
  189. (*      file sequentially beginning with line number 1.  In the              *)
  190. (*      descriptions below "x" denotes the line number of the line           *)
  191. (*      currently displayed at the top of the viewing window.                *)
  192. (*                                                                           *)
  193. (*      L or +L: Skip forwards one line, i.e., display the 24 lines          *)
  194. (*         starting with line number x+1.  This effectively scrolls          *)
  195. (*         the window down one line (or, if you prefer, scrolls the          *)
  196. (*         text up one line).                                                *)
  197. (*         You can also use the down-arrow key (keypad key 2).               *)
  198. (*      -L: Skip backwards one line, i.e., display the 24 lines              *)
  199. (*         starting with line number x-1.  This effectively scrolls          *)
  200. (*         the window up one line (or, if you prefer, scrolls the            *)
  201. (*         text down one line).                                              *)
  202. (*         You can also use the up-arrow key (keypad key 8).                 *)
  203. (*      nL or +nL: Skip forwards n lines, i.e., display the 24 lines         *)
  204. (*         starting with line number x+n.                                    *)
  205. (*      -nL: Skip backwards n lines, i.e., display the 24 lines              *)
  206. (*         starting with line number x-n.                                    *)
  207. (*      Ln: Skip to absolute line number n, i.e., display the 24 lines       *)
  208. (*         starting with line number n.                                      *)
  209. (*                                                                           *)
  210. (*      Notes.  The relative line positioning commands can be used with      *)
  211. (*      a small forwards or backwards skip count to "slide" the viewing      *)
  212. (*      window a "little bit" forwards or backward, to exactly position      *)
  213. (*      the viewing window with respect to some item of interest.  For       *)
  214. (*      example, suppose a table appears on the current screen, starting     *)
  215. (*      at the fourth line of the screen.  The command "3L" would slide      *)
  216. (*      the window forwards 3 lines, so that the first line of the table     *)
  217. (*      is at the top of the screen.  "L0" or "L1" may be used to skip       *)
  218. (*      backwards to the beginning of the file.                              *)
  219. (*                                                                           *)
  220. (*   Column positioning commmands                                            *)
  221. (*   ------ ----------- ---------                                            *)
  222. (*                                                                           *)
  223. (*      The three command groups described above are all used to position    *)
  224. (*      the viewing window vertically within the file.  The remaining        *)
  225. (*      two groups are used to position the window horizontally within       *)
  226. (*      the file.                                                            *)
  227. (*                                                                           *)
  228. (*      The column positioning commands are used to move the viewing window  *)
  229. (*      left or right across the file.  The same set of lines is redisplayed *)
  230. (*      after the command is entered, with the new setting for the left      *)
  231. (*      column.                                                              *)
  232. (*                                                                           *)
  233. (*      C or +C: Move the window right one column.                           *)
  234. (*      -C: Move the window left one column.                                 *)
  235. (*      nC or +nC: Move the window right n columns.                          *)
  236. (*      -nC: Move the window left n columns.                                 *)
  237. (*      Cn: Reset the leftmost window column to be column n, i.e., move      *)
  238. (*         the window to column n.                                           *)
  239. (*      Pressing the right arrow (keypad key 6) moves the window right 10    *)
  240. (*         columns.                                                          *)
  241. (*      Pressing the left arrow (keypad key 4) moves the window left 10      *)
  242. (*         columns.                                                          *)
  243. (*                                                                           *)
  244. (*   Width setting commands                                                  *)
  245. (*   ----- ------- --------                                                  *)
  246. (*                                                                           *)
  247. (*      These commands reset the width of the viewing window, i.e., the      *)
  248. (*      number of columns displayed across the screen for each line.         *)
  249. (*                                                                           *)
  250. (*      W or +W: Increment the width by one column.                          *)
  251. (*      -W: Decrement the width by one column.                               *)
  252. (*      nW or +nW: Increment the width by n columns.                         *)
  253. (*      -nW: Decrement the width by n columns.                               *)
  254. (*      Wn: Set the width to n columns.                                      *)
  255. (*                                                                           *)
  256. (*      Note:  If you set the width to something larger than 80, lines will  *)
  257. (*             wrap and the screen display will be wrong, unless you have    *)
  258. (*             some kind of special display adapter that allows more than    *)
  259. (*             80 columns.                                                   *)
  260. (*                                                                           *)
  261. (*   File formats                                                            *)
  262. (*   ---- -------                                                            *)
  263. (*                                                                           *)
  264. (*      Line printer carriage control (/LPC).  These files use column 1 for  *)
  265. (*      special line printer carriage control characters.  In particular,    *)
  266. (*      a "1" in column 1 signals the first line of a new page.  This        *)
  267. (*      column is always displayed by PIBLIST as the first column of the     *)
  268. (*      viewing window, even if the first display column has been set        *)
  269. (*      to some column greater than 1.  For example, if a C5 command         *)
  270. (*      is used and your window width is 80 columns, then PIBLIST would      *)
  271. (*      display columns 1 and 5 through 83 of each line.                     *)
  272. (*                                                                           *)
  273. (*      Form feed carriage control (/FF).  These files do not use column 1   *)
  274. (*      for anything special - column 1 simply contains the first regular    *)
  275. (*      text character for each line.  A form feed in column 1 signals       *)
  276. (*      the first line of a new page.  PIBLIST displays form feeds as <FF>.  *)
  277. (*      The first column is displayed only if the first display column       *)
  278. (*      is set to 1.  For example, C5 and W80 would result in columns        *)
  279. (*      5 through 84 being displayed.                                        *)
  280. (*                                                                           *)
  281. (*
  282. (*                                                                           *)
  283. (*   Initial settings                                                        *)
  284. (*   ------- --------                                                        *)
  285. (*                                                                           *)
  286. (*      PIBLIST begins by reading the first 'max-buf-lines' lines into       *)
  287. (*      an internal buffer.  It then displays the first 24 lines on          *)
  288. (*      the file.  Appropriate settings for the first display column         *)
  289. (*      and the window width are chosen by examining these first buffered    *)
  290. (*      lines.  'max-buf-lines' is currently set to 100.                     *)
  291. (*                                                                           *)
  292. (*      The initial setting for the window width is 80 columns.              *)
  293. (*      If none one of the first buffered lines                              *)
  294. (*      on the file exceed this width then the first display column is       *)
  295. (*      set to column 1.  If at least one of the first buffered lines does   *)
  296. (*      extend beyond the width setting then PIBLIST attempts to choose the  *)
  297. (*      smallest value for the first display column such that each line      *)
  298. (*      fits in the window.  This is done only if no characters other than   *)
  299. (*      spaces, form feeds, or printer carriage control character (if the    *)
  300. (*      file has them) are lost.  For example, suppose you are viewing a     *)
  301. (*      text-formatter output file with one column of carriage control,      *)
  302. (*      seven blank columns for the left margin, and 75 columns of text.     *)
  303. (*      PIBLIST would automatically initialize the first display column to   *)
  304. (*      column 5, so that each line fits in the window.  The columns         *)
  305. (*      displayed would be column 1 (the printer carriage control character) *)
  306. (*      and columns 5 through 83 (the last text column).  Columns 2, 3, and  *)
  307. (*      4 are blank columns and are not displayed.                           *)
  308. (*                                                                           *)
  309. (*      In all cases PIBLIST trims trailing blanks from lines before         *)
  310. (*      computing the length.  If /T appears on the PIBLIST control          *)
  311. (*      statement then embedded tab characters are also expanded into the    *)
  312. (*      proper number of blanks (1 to 8) before the line length computation  *)
  313. (*      is performed.                                                        *)
  314. (*                                                                           *)
  315. (*      PIBLIST clears the screen on exit.                                   *)
  316. (*                                                                           *)
  317. (*                                                                           *)
  318. (*   Other notes                                                             *)
  319. (*   ----- -----                                                             *)
  320. (*                                                                           *)
  321. (*      When the end of the file is reached PIBLIST displays the extra       *)
  322. (*      line "<End of file>".  If a vertical positioning command             *)
  323. (*      is used that tries to skip forwards past the end of the              *)
  324. (*      file then this message is all that is displayed.                     *)
  325. (*                                                                           *)
  326. (*      PIBLIST maintains an internal buffer of contiguous text lines.       *)
  327. (*      The buffer usually contains either 'max-buf-lines' lines or          *)
  328. (*      'max-buf-pages of text, whichever is smaller.  Currently,            *)
  329. (*      'max-buf-lines' is 100, and 'max-buf-pages' is 5.  The viewing       *)
  330. (*      window of 24 lines is always contained in the buffer, usually        *)
  331. (*      at the end.  Vertical positioning commands that skip to a line       *)
  332. (*      currently in the buffer are very fast.  For this reason              *)
  333. (*      backwards skips of up to 4 or 5 pages are usually very fast.         *)
  334. (*      For longer backwards skips PIBLIST rewinds the file and skips        *)
  335. (*      forwards to find the requested line.  This can take a long           *)
  336. (*      time if the file is large and the requested line is not near         *)
  337. (*      the beginning of the file.                                           *)
  338. (*                                                                           *)
  339. (*      Unprintable characters are displayed by PIBLIST as <XXX>, where      *)
  340. (*      "XXX" is the ASCII mnemonic for the character.                       *)
  341. (*                                                                           *)
  342. (*      If the file to be listed is empty PIBLIST issues an error message    *)
  343. (*      and aborts.                                                          *)
  344. (*                                                                           *)
  345. (*---------------------------------------------------------------------------*)
  346. (*                                                                           *)
  347. (*   The text buffer                                                         *)
  348. (*   ---------------                                                         *)
  349. (*                                                                           *)
  350. (*   PIBLIST uses a text line buffer to help make short backwards            *)
  351. (*   skips more efficient.                                                   *)
  352. (*                                                                           *)
  353. (*   The buffer is organized as a circular linked list of lines.             *)
  354. (*   Each line in the list contains a pointer to the next line,              *)
  355. (*   the line number and page number of the line, the length of              *)
  356. (*   the line, and the text of the line.  The buffer records are             *)
  357. (*   allocated and linked together at initialization.  The lines             *)
  358. (*   are never deallocated, and the links are never changed after            *)
  359. (*   they have been initialized.                                             *)
  360. (*                                                                           *)
  361. (*   At any point in the program the buffer may contain anywhere             *)
  362. (*   from 0 to max-buf-lines contiguous lines of text from the file.  The    *)
  363. (*   global variables first and last point to the first and last             *)
  364. (*   lines in the buffer respectively.  If the buffer is empty               *)
  365. (*   (a fairly rare occurrence) then last is set to nil and first            *)
  366. (*   points to some arbitrary element of the list.                           *)
  367. (*                                                                           *)
  368. (*   All text lines are stored in the buffer with tabs expanded (if /T)      *)
  369. (*   and trailing blanks trimmed.  If /H is specified, then the high-order   *)
  370. (*   bit of each character is stripped before before the line is stored in   *)
  371. (*   the buffer.  Other unprintable characters, however, are stored as is -  *)
  372. (*   they are not replaced by their ASCII mnemonics until the line is        *)
  373. (*   displayed.                                                              *)
  374. (*                                                                           *)
  375. (*   The viewing window constitutes a subset of the buffer, and may          *)
  376. (*   be located anywhere within the buffer.  The global variables            *)
  377. (*   Top and Bot point to the top and bottom of the viewing window           *)
  378. (*   respectively.                                                           *)
  379. (*                                                                           *)
  380. (*   The file being listed is always positioned at the beginning of          *)
  381. (*   the line immediately following the last line in the buffer.             *)
  382. (*   The global variables cur_line and cur_page keep track of the            *)
  383. (*   line and page number of this next line on the file.                     *)
  384. (*                                                                           *)
  385. (*   The circular buffer is the only complex data structure used             *)
  386. (*   by PIBLIST.  The remaining global variables are (I hope)                *)
  387. (*   self-explanatory.                                                       *)
  388. (*                                                                           *)
  389. (*---------------------------------------------------------------------------*)
  390. (*                                                                           *)
  391. (*   Acknowledgements                                                        *)
  392. (*   ----------------                                                        *)
  393. (*                                                                           *)
  394. (*   PIBLIST is based upon John Norstad's LIST program for VAX/VMS and the   *)
  395. (*   LISTxx programs of Vernon Buerg.                                        *)
  396. (*                                                                           *)
  397. (*---------------------------------------------------------------------------*)
  398.